package com.dlts.freemarker.controller;


import com.dlts.freemarker.model.table.*;
import com.dlts.freemarker.service.TablesService;
import com.dlts.freemarker.model.R;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author DLTS
 * @since 2022-01-11
 */
@RestController
@RequestMapping("/tables")
@AllArgsConstructor
public class TablesController {

    private TablesService tablesService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "表-分页查询",notes = "谢百庆")
    public R<TablesPageQueryVO> pageQuery(@RequestBody @Valid TablesPageQueryDTO dto){
        return R.ok(tablesService.pageQuery(dto));
    }

    @PostMapping("/detail")
    @ApiOperation(value = "表-详情",notes = "谢百庆")
    public R<TablesDetailVO> detail(@RequestBody @Valid TablesDetailDTO dto){
        return R.ok("查询成功").setData(tablesService.detail(dto));
    }

    @GetMapping("/selector")
    @ApiOperation(value = "表-下拉列表选择器",notes = "谢百庆")
    public R<List<TableSelectorVO>> selector(){
        return R.ok("查询成功").setData(tablesService.selector());
    }

}
